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

Aggiunge automazione per formattare il codice prima di ogni commit #115

Merged
merged 12 commits into from
Sep 27, 2023
5 changes: 4 additions & 1 deletion .github/workflows/formatting-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Prettier Check
run: npx prettier --check "**/*.md"
run: npm run format:check
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.18.0
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Tutti i file markdown devono essere formattati con [Prettier](https://prettier.i
Per formattare da linea di comando tutti i file è necessario avere [Node](https://nodejs.org/it) installato sul proprio computer e lanciare il seguente comando nella cartella del repository:

```bash
npm run format
npm run format:write
elgorditosalsero marked this conversation as resolved.
Show resolved Hide resolved
```

Fortunatamente i principali IDE supportano Prettier tramite delle estensioni, di seguito alcuni esempi:
Expand Down
12 changes: 12 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
colors: true
pre-commit:
commands:
prettier:
glob: "*.md"
run: npm run format:write {staged_files}
pre-push:
commands:
format-check:
glob: "*.md"
run: npm run format:check

125 changes: 125 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"scripts": {
"format": "prettier --write ."
"format:check": "npx prettier --check \"**/*.md\"",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggerimento: Non utilizzerei npx per avviare Prettier avendolo già installato nelle dipendenze.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, credo che sia stato inserito per evitare di installare le devDeps direttamente dalla action. È strettamente necessario secondo voi?

Personalmente "normalizzerei" gli scripts in maniera tale che vengano tutti avviati in un'unica maniera.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Al momento è l'unica action che abbiamo e che ha bisogno di node.

Volendo si può rimuovere node e lanciare il comando a mano, ma poi se si cambia nel package.json andrebbe cambiato anche nella actions.

Sinceramente non installerei le deps e non le metterei nemmeno in cache, o almeno, non al momento.

"format:write": "prettier --write",
"prepare": "husky install"
elgorditosalsero marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"lefthook": "^1.5.0",
"prettier": "^3.0.2"
}
}