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 Prettier configurations #96

Open
mure opened this issue Jun 30, 2022 · 6 comments
Open

Add Prettier configurations #96

mure opened this issue Jun 30, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@mure
Copy link
Collaborator

mure commented Jun 30, 2022

https://prettier.io/

@mure mure added the enhancement New feature or request label Jun 30, 2022
@pakdev
Copy link

pakdev commented Nov 1, 2023

I concur. Prettier improves consistency and lightens developer burden.

Edit: I don't care if the formatter we use is prettier or something else. It'd just be nice to have a tool automatically format my code

@rajsite
Copy link
Member

rajsite commented Nov 1, 2023

Mentioned to @pakdev that you can use prettier-eslint (like Nimble does) with prettier so that the NI Eslint rules are followed but sounded like the goal was to get the NI JavaScript Styleguide to recommend that by default instead of per project / code base / team.

@pakdev
Copy link

pakdev commented Nov 1, 2023

According to the prettier-eslint project:

This formats your code via prettier, and then passes the result of that to eslint --fix. This way you can get the benefits of prettier's superior formatting capabilities, but also benefit from the configuration capabilities of eslint

So, this project isn't any different from manually configuring prettier to adhere to our eslint rules. I was able to accomplish that for Javascript with this simple config:

{
    "arrowParens": "avoid",
    "printWidth": <you choose>,
    "singleQuote": true,
    "tabWidth": 4,
    "trailingComma": "none",
    "overrides": [
        {
            "files": "**/*.yaml",
            "options": {
                "tabWidth": 2,
                "singleQuote": false
            }
        }
    ]
}

Note: It's possible there are other settings required that just haven't been exercised in the code I formatted. Because of that uncertainty, prettier-eslint is beneficial as it infers a prettier config from eslint's config. However, my point is prettier-eslint isn't somehow avoiding the "should we use prettier" debate (in part or in whole)

@pakdev
Copy link

pakdev commented Nov 1, 2023

NI JavaScript Styleguide to recommend that by default instead of per project / code base / team.

And maybe this recommendation would be too big of a pill for the NI Javascript Styleguide to swallow. The alternative is to at least allow its usage on a developer-by-developer basis. What do you think about the following guidance?

"Individual developers are allowed (and encouraged) to use code formatting tools as they see fit so long as their changes do not conflict with the established eslint rules of this guide. However, if their code formatter introduces changes outside of the code they're directly modifying, they must first submit the code formatter changes in a separate PR."

@TrevorKarjanis
Copy link
Collaborator

NI JavaScript Styleguide to recommend that by default instead of per project / code base / team.

And maybe this recommendation would be too big of a pill for the NI Javascript Styleguide to swallow. The alternative is to at least allow its usage on a developer-by-developer basis. What do you think about the following guidance?

"Individual developers are allowed (and encouraged) to use code formatting tools as they see fit so long as their changes do not conflict with the established eslint rules of this guide. However, if their code formatter introduces changes outside of the code they're directly modifying, they must first submit the code formatter changes in a separate PR."

This will just result in constant formatting changes when not all developers are using Prettier in a repository. Therefore, maybe should be repository by repository.

@pakdev
Copy link

pakdev commented Nov 1, 2023

This will just result in constant formatting changes when not all developers are using Prettier in a repository. Therefore, maybe should be repository by repository.

Maybe. I'd be curious to see if that's the case though and why - especially if this project provides prettier/<code formatter> config(s). Perhaps we could fix these inconsistencies by activating more eslint rules (or making the formatter less opinionated, though that's my least favorite approach)

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

No branches or pull requests

4 participants